home *** CD-ROM | disk | FTP | other *** search
/ Acorn RISC PD-CD 1 / Acorn RISC PD-CD 1.iso / utilities / _graphics / graphics / _drawlots / interhelp < prev   
Encoding:
Text File  |  1992-06-06  |  21.7 KB  |  620 lines

  1. Interface 2.00 
  2. © Software Interrupt 1990
  3.  
  4. See notes at end for update info......
  5.  
  6. This manual and software is public domain.  It may be copied and distributed
  7. freely as long as:
  8.  
  9.     It is not separated from the documentation (except for commercial use)
  10.     The module is not tampered with
  11.     You do not claim that you have written the module
  12.     Do not use any of the code contained in this module in your own code
  13.  
  14. If you wish to use this in a commercial product please contact me so that I
  15. can make sure you have the latest release, please send a disk.
  16.  
  17. In no circumstances shall the author be liable for any damage, loss of
  18. profits, time or data or any indirect or consequential loss rising out of
  19. the use of this software or inability to use this software.
  20.  
  21. Contacts:
  22.        Arcade BBS          (081 654 2212)                   
  23.        The World Of Cryton (0749 679794)     
  24.  
  25.        All mail on the above Bulletin Bords should be mailed to JICK
  26.  
  27. **************** Introduction ***********************************************
  28.  
  29. Interface is a small module that allows application programmers to implement
  30. a colourful and pleasant graphical user interface.  Interface provides many
  31. more functions that allows you to change the pointer shape easily and to
  32. interface with the !Help or !Spy application.
  33.  
  34. The Interface module provides functions to improve the friendliness and
  35. appearance of the application. The application should still operate as
  36. stated in the Acorn guidelines in the Programmers Reference Manuals.
  37.  
  38. The module implements a number of SWIs which are described further in this 
  39. manual, these SWI calls can be called from any language.  Most of the
  40. functions provided are specified in the icons validation string, and so no
  41. complex programming is needed to make the application look good.
  42.  
  43. This guide tells you how to fully implement the features of Interface. It is
  44. split into the follow sections:
  45.  
  46.    The first section explains the validation strings options provided
  47.    by Interface.
  48.    The next section gives details of the SWI calls provided.
  49.    The remaining section covers hints and tips on programming.
  50.  
  51.  
  52.  
  53. **************** Technical details ******************************************
  54.  
  55. An indirected text icon can have a validation string which is used to pass
  56. further information to the WIMP, such as what border type the icon has and
  57. also what pointer, if any should be displayed whilst over this icon. The
  58. syntax of a validation string is:
  59.  
  60.   validation string ::- command {;command}*
  61.   command           ::- (b | z) border-type {border-spec} | 
  62.                         r on/off-type {,icon-number}* |
  63.                         u on/off-type {,icon-number}* |
  64.                         p text-string {,x} {,y} |
  65.                         i text-string |
  66.                         k key-code
  67.   border-spec       ::- {,button-slabbing-mask} {,slabbing-time} {,colour}*
  68.  
  69. The parameters above are described under the relevant validation command.
  70. In simple terms, a validation string consists of a series of 'commands',
  71. each starting with a single letter and seperated from the following command
  72. by a semi-colon. {}* means zero or more of the thing inside the {}. The
  73. following commands are available with the Interface module.
  74.  
  75. These commands are provided in addition to the standard Wimp validation
  76. strings. I suggest that you edit the !FormEd program to allow you to enter
  77. larger validation strings, otherwise when entering a help command you will
  78. only be allowed a maximum of 80 characters.
  79.  
  80. The (B)order command tells Interface which border to use when rendering an
  81. icon. The border types available at present are :
  82.  
  83.    border type 0, this is a single border used mainly for headings and
  84.      action icons. The icon will slab inwards if the user clicks a button
  85.      whilst the pointer is over the icon providing it is not setup to ignore
  86.      mouse clicks.
  87.  
  88.    border type 1, this is a double border and should be used to group
  89.      together icons that perform an operation.
  90.  
  91.    border type 2, this is a triple border and should be used on the default
  92.      action button. The icon will slab inwards when the user clicks a button
  93.      whilst the pointer is over this icon providing it is not setup to
  94.      ignore mouse clicks.
  95.  
  96.    border type 3, this is a wide inverted border and should be used on
  97.      writable icons. This border type is usually used in-conjunction with
  98.      the writable pointer.
  99.         
  100.    border type 4, this is an inverted version of border type 0
  101.        
  102.    border type 5, this is a double wide border as used by acorn in ros 3
  103.         
  104.    border type 6, etched in border
  105.         
  106.    border type 7, similar to border type 0, thinner in mode 20
  107.  
  108. The second optional parameter is the button slabbing mask, this states
  109. whether the icon should be slabbed until the button is released. The values
  110. contained in this parameter can be from 0 to 7. The button slabbing mask can
  111. be calculated in the following way:
  112.  
  113.         Value   Button          Meaning
  114.         1       Adjust  slab icon until adjust is released
  115.         2       Menu    slab icon until menu is released
  116.         4       Select  slab icon until select is released
  117.  
  118. The button slabbing mask can then be calculated by adding together the
  119. required button values.  
  120.  
  121. The button slabbing time is the minimum time that the icon will be slabbed
  122. for, the default time is for 15cs.  This value is a decimal number in
  123. centi-seconds. The colours are specified in the following order:
  124.  
  125.         {,border colour1} {,border colour2} {,slabbing out colour} 
  126.         {,slabbing in colour} {,inner channel colour}
  127.  
  128. These colours can be any valid WIMP colour in the range of 0 to 15, the 
  129. default selection is 4, 0, 1, 14, 12.
  130.  
  131. The (R)adio command specified in the validation string is used to set the
  132. state of other radio button type icons.  The R command is followed by a
  133. decimal number in the range 0 to 2, the action that these perform is:
  134.  
  135. Radio type              Operation
  136.   0               this has the effect of switching off the specified icon(s).
  137.   1               this has the effect of switching on the specified icon(s).   2               this has the effect of toggling the icons current state.
  138.  
  139. This command is then followed by the numbers of the icons you wish to alter,
  140. these should be separated by commas. This command may be specified more than
  141. once in a validation string, for example to switch icons 1 & 2 off, 3 & 4 on
  142. and toggle the state of icons 5 & 6 you could use the following validation
  143. string
  144.  
  145.         R0,1,2;R1,3,4;R2,5,6
  146.  
  147. The (U)nselectable command in the validation string has the effect of
  148. shading the icon grey so that it cannot be selected by the user. It is
  149. followed by a decimal number in the range 0 to 2, the action that these is
  150. described above in the radio command.
  151.  
  152. This command is then followed by the numbers of the icons you wish to alter,
  153. these should be separated by commas.  This command may be specified more
  154. than once in a validation string, for example to shade icons 1 & 2, un-shade
  155. 3 & 4 and toggle the state of icons 5 & 6 you could use the following
  156. validation string
  157.  
  158.         U0,1,2;U1,3,4;U2,5,6
  159.  
  160. The (P)ointer command is used to define a pointer to be displayed when the
  161. pointer is over that icon.  The first parameter is a sprite name to use for
  162. the pointer, this should be no longer than 12 characters and should be
  163. present in the WIMP sprite pool. The optional parameters specify the x and y
  164. offsets to the active point in the sprite, these should be specified in
  165. pixels.
  166.  
  167. The (I)nformation command is used to define a message to be sent to the
  168. interactive help application when the pointer is over the icon. If you wish
  169. to use a semi-colon then you must place two next to each other. The maximum
  170. length of the help message is 235 characters.
  171.  
  172. The Interface module will change to the specified pointer when the mouse
  173. pointer is over the icon/workarea, if no pointer is specified then the
  174. pointer will default to shape one (the default arrow shape). There are 5
  175. pointer shapes designed in the sprite file in the !Interface directory,
  176. these are:
  177.  
  178.    ptr_write - this pointer should be used on writable icons, the suggested
  179.      active point is at coordinates x = 4, y = 4.
  180.  
  181.    ptr_menu - this pointer is used where a menu can be activated by pressing
  182.      the menu button over the icon.  This stops the user having to search
  183.      all over the window to find where the menu is. The suggested active
  184.      point is x = 6, y = 5.
  185.  
  186.    ptr_direct - this pointer is used where an object may be re-sized, the
  187.      suggested active point is at x = 13, y = 7.
  188.  
  189.    ptr_hand - this pointer is used where and icon may be dragged.  It is
  190.      usually set on the workarea, but it can be used on any icon (the save
  191.      file icon looks great when using it), its suggested active point is at
  192.      x = 12, y = 8.
  193.  
  194.    ptr_cross - this pointer is used as a crosshair, it is the same as the
  195.      one used in the Draw application. This icon gives the user a precise
  196.      point when working with line drawings, its suggested active point is at
  197.      x = 13, y = 7.
  198.  
  199. You may also design your own pointers, which should be loaded into the WIMP
  200. sprite pool.  There are a few points that you should note when designing
  201. pointers these are :
  202.  
  203. Pointer sprite names should have the form ptr_XXXXX, although this is not
  204. compulsory it helps so that you do not get confused with pointers and normal
  205. sprites.
  206.  
  207. Do not use logical colour 2 in the pointer sprites, as this is unavailable
  208. in very high resolution modes.
  209.  
  210. The pointers used should only be valid in your application, so you must not
  211. mask out the Pointer_Leaving_Window in your application. You should claim
  212. Null_Reason_Code when passed to your application, otherwise the pointer will
  213. not change when the pointer is over the icon/workarea, see the examples for
  214. more.
  215.  
  216. You should support the !Help application to help new users using your
  217. application, this is why I implemented a feature in Interface to make this
  218. easier. The following was for some reason not published in the Programmers
  219. Reference Manuals, but was in the pre-release disc version of the manuals.
  220.  
  221. For an application to use interactive help, two WIMP messages are employed.
  222. One is used by the Help to request help, and the other is used by the
  223. application to return the help message.
  224.  
  225. To request help, the Help application sends a message of the following form:
  226.  
  227. block   +16     &502 - indicates request for help
  228.                 +20     mouse x co-ordinate
  229.                 +24     mouse y co-ordinate
  230.                 +28     mouse button state
  231.                 +32     window handle               (-1 if not over a window)
  232.                 +36     icon handle                 (-1 if not over an icon)
  233.  
  234. The WIMP system will pass this message automatically to the task in charge
  235. of the appropriate window/icon. If the application receiving the message
  236. wishes to produce some help, it should respond with the following message:
  237.  
  238. block   +16     &503
  239.                 +20     help message terminated by 0
  240.  
  241. This message can be sent to the Help application by using Wimp_SendHelp,
  242. which is provided by the Interface module (SWI &81687).
  243.  
  244. The help text may  contain any printable character codes. If the sequence |M
  245. is encountered then this will be treated as a line break and subsequent text
  246. will be printed on the next line in the window. If the text is too long for
  247. one line then it will be split at a word boundary (space character).
  248.  
  249. The text should consist of  simple complete English sentences, each starting
  250. on a new line and ending with a full stop. The sentences should usually be
  251. simple imperatives or information such as:
  252.  
  253.         Click SELECT to set the alarm.
  254.  
  255.         You are in Select mode.
  256.  
  257.         Click ADJUST to change to path edit mode.
  258.  
  259.         This is the icon for Edit.
  260.  
  261. In general you need not mention menu entries, except when specific ones
  262. interact with pointer operations. As a general rule present information of
  263. interest to the beginner near the top, and expert tips or information lower
  264. down.
  265.  
  266. You must use the terminology defined. For mouse operations you must use
  267. initial capitals (for example Click). The mouse buttons must be in capitals
  268. (for example SELECT), as must key names (for example ESC, RETURN, SHIFT,
  269. CONTROL, A, B, F1, COPY). miss out speedups and shortcuts - just provide
  270. enough to help a beginner without drowning them with information.
  271.  
  272. Provide interactive help thoroughly - include the icon bar, and the workarea
  273. of all your windows.  If no actions are possible in a window, just
  274.  
  275.         This window shows....
  276.  
  277. is better than nothing.
  278.  
  279. You should assume a user knows:
  280.  
  281.         what a MENU key is
  282.         how to navigate menu trees and choose entries
  283.         what the icon bar is
  284.         how to move/size/toggle/close windows, and so on
  285.         what 'dragging an icon' means
  286.         what 'filling in a field' (writable icon) means
  287.  
  288. The keycode command should be placed in the icon that is activated by the 
  289. keycode.  It should be a decimal integer specifying the key.  The up/down
  290. arrows, tab etc.. are dealt with.
  291.  
  292.  
  293. **************************** The SWI Calls *********************************
  294.  
  295. Wimp_BorderIcon (Interface_SlabButton) (SWI &81680)
  296.  
  297. R1 = pointer to block
  298. R1 preserved
  299.  
  300. Interrupts are not defined
  301. Fast interrupts are enabled
  302.  
  303. Processor is in SVC mode
  304.  
  305. SWI is not re-entrant
  306.  
  307. The block contains the following on entry:
  308.  
  309.         R1+0    mouse x (screen coordinates - not window relative)
  310.         R1+4    mouse y
  311.         R1+8    buttons (depending on icon button type)
  312.         R1+12   window handle
  313.         R1+16   icon handle  
  314.  
  315. This call is used to update an icons border.  It is typically called as a
  316. result of a Mouse_Click event, if the icon has a border type of 0 or 2 then
  317. the icon will slab inwards. The format of the validation string is described
  318. in the previous section.
  319.  
  320. The application should the perform the task and then force the icon to normal
  321. status by calling Wimp_BorderIcon (SWI &81680) with R1+8 set to 0.
  322.  
  323. The code to border icons and windows is outlined in the section Programming 
  324. Interface. 
  325.  
  326. Note that the mouse coordinates specified in R1+0 and R1+4 are not used by
  327. the SWI and are only present to make the block compatible with a Mouse_Click
  328. event block.
  329.  
  330. Wimp_BorderWindow (SWI &81681)
  331.  
  332. None
  333.  
  334.  
  335.  
  336.  
  337.  
  338. Wimp_BorderWindow (Interface_Render3dWindow) (SWI &81681)
  339.  
  340. R1 = pointer to block
  341. R1 preserved
  342.  
  343. Interrupts are not defined
  344. Fast interrupts are enabled
  345.  
  346. Processor is in SVC mode
  347.  
  348. SWI is not re-entrant
  349.  
  350. The block contains the following on entry:
  351.  
  352.         R1+0    window handle
  353.         R1+4    visible area minimum x coordinate
  354.         R1+8    visible area minimum y coordinate
  355.         R1+12   visible area maximum x coordinate
  356.         R1+16   visible area maximum y coordinate
  357.         R1+20   scroll x offset relative to work area origin
  358.         R1+24   scroll y offset relative to work area origin
  359.         R1+28   current graphics window minimum x coordinate
  360.         R1+32   current graphics window minimum y coordinate
  361.         R1+36   current graphics window maximum x coordinate
  362.         R1+40   current graphics window maximum y coordinate
  363.  
  364. This call is used to redraw the borders of icons in the window that are not
  365. up-to-date, this SWI is typically called during the redraw loop of a window.
  366. The SWI will update the window, drawing borders around any icons which have
  367. the b command specified in the validation string and are within the
  368. specified graphics window.
  369.  
  370. The code to border icons and windows is outlined in the section Programming 
  371. Interface. 
  372.  
  373. Wimp_BorderIcon (SWI &81680)
  374.  
  375. None 
  376.  
  377.  
  378.  
  379.  
  380. Wimp_ClaimInterface (Interface_Initialise) (SWI &81682)
  381.  
  382. R0 = task handle
  383. R0 preserved
  384.  
  385. Interrupts are not defined
  386. Fast interrupts are enabled
  387.  
  388. Processor is in SVC mode
  389.  
  390. SWI is not re-entrant
  391.  
  392. This SWI allows your application to use pointers via the Interface module.
  393. This SWI should be called at the beginning of your program. If you don't use 
  394. Wimp_ClaimInterface then your pointers will not be displayed.
  395.  
  396. Wimp_ReleaseInterface (SWI &81683)
  397.  
  398. None
  399.  
  400.  
  401.  
  402.  
  403. Wimp_ReleaseInterface (Interface_CloseDown) (SWI &81683)
  404.  
  405. R0 = task handle
  406. R0 preserved
  407.  
  408. Interrupts are not defined
  409. Fast interrupts are enabled
  410.  
  411. Processor is in SVC mode
  412.  
  413. SWI is not re-entrant
  414.  
  415. This SWI stops your application from using pointers. When this SWI is called 
  416. Interface Manager will erase any workarea pointers assigned to your
  417. application and free the memory. This should be called in your exit handler,
  418. also if an error occurs you should also call this SWI to stop other
  419. applications from gaining your pointers.
  420.  
  421. Wimp_ClaimInterface (SWI &81682)
  422.  
  423. None
  424.  
  425.  
  426.  
  427.  
  428. Wimp_SetWorkareaPointer (Interface_SetWorkareaPointer) (SWI &81684)
  429.  
  430. R1 = pointer to block
  431. R1 preserved
  432.  
  433. Interrupt status is undefined
  434. Fast interrupts are enabled
  435.  
  436. Processor is in SVC mode
  437.  
  438. SWI is not re-entrant
  439.  
  440. The block contains the following on entry:
  441.  
  442.         R1+0    window handle
  443.         R1+4    minimum x coordinate of bounding box
  444.         R1+8    minimum y coordinate of bounding box
  445.         R1+12   maximum x coordinate of bounding box
  446.         R1+16   maximum y coordinate of bounding box
  447.         R1+20   24 bytes of pointer data
  448.  
  449. This specifies the pointer for an area of the window.
  450. The bounding box coordinates are given relative to the window's work area
  451. origin. R1+4 to R1+16 can be set to -1 to specify the whole of the window's
  452. work area. The pointer data at +20 to +44 contains the sprite name and any
  453. x, y offset, see validation strings for more information.
  454.  
  455. Wimp_RemoveWorkareaPointer (SWI &81685)
  456. Wimp_PollPointer (SWI &81686)
  457.  
  458. None
  459.  
  460.  
  461.  
  462.  
  463.  
  464. Wimp_RemoveWorkareaPointer (Interface_RemoveWorkareaPointer) (SWI &81685)
  465.  
  466. R0 = task handle
  467. R1 = pointer to block
  468.  
  469. R0 preserved
  470. R1 preserved
  471.  
  472. Interrupt status is undefined
  473. Fast interrupts are enabled
  474.  
  475. Processor is in SVC mode
  476.  
  477. SWI is not re-entrant
  478.  
  479. The block contains the following on entry:
  480.  
  481.         R1+0    window handle
  482.         R1+4    minimum x coordinate of bounding box
  483.         R1+8    minimum y coordinate of bounding box
  484.         R1+12   maximum x coordinate of bounding box
  485.         R1+16   maximum y coordinate of bounding box
  486.  
  487. This call removes a previously installed pointer from the list of active
  488. pointer areas for the specified window. When a window is deleted you should
  489. remove any pointers that were related to the window, otherwise these
  490. pointers may become active on any window which gains the same window handle
  491. in the future.
  492.  
  493. The bounding box coordinates are given relative to the window's work area
  494. origin. R1+4 to R1+16 can be set to -1 to specify the whole of the window's
  495. work area. R1+4 to R1+16 may be set to 0 to remove all work area pointers
  496. assigned to the window.
  497.  
  498. Wimp_SetWorkareaPointer (SWI &81684)
  499. Wimp_PollPointer (SWI &81686)
  500.  
  501. None
  502.  
  503.  
  504.  
  505.  
  506.  
  507. Wimp_PollPointer (Interface_Poll) (SWI &81686)
  508.  
  509. R0 = Wimp_Poll reason code
  510. R2 = task handle
  511.  
  512. R0 preserved
  513. R@ preserved
  514.  
  515. Interrupt status is undefined
  516. Fast interrupts are enabled
  517.  
  518. Processor is in SVC mode
  519.  
  520. SWI not re-entrant
  521.  
  522. This call checks to see if the pointer is up-to-date. If the pointer is not
  523. up-to-date it will change to the pointer specified in the icons validation
  524. string. If the pointer is not over an icon then the pointer will change
  525. according to the position on the window background.
  526.  
  527. Note that wimp_poll reason codes 0 and 4 should not be masked out, otherwise
  528. the pointer will be out-of-date and will not function correctly.
  529.  
  530. Wimp_SetWorkareaPointer (SWI &81684)
  531. Wimp_RemoveWorkareaPointer (SWI &81685)
  532.  
  533. None
  534.  
  535.  
  536.  
  537.  
  538.  
  539. Wimp_SendInformation (Interface_SendHelp) (SWI &81687)
  540.  
  541. R1 = message block as returned from help application
  542. R1 preserved
  543.  
  544. Interrupt status is undefined
  545. Fast interrupts are enabled
  546.  
  547. Processor is in SVC mode
  548.  
  549. SWI not re-entrant
  550.  
  551. This call returns a help text message to the interactive help application.
  552. It should be called when a message with the number &502 is received and the
  553. pointer is over an icon. If there is a message in the icons validation string
  554. that the pointer is currently over then this will be sent to the help
  555. application. It is up to the applications programmer to take care of the
  556. help message when the pointer is over the icon on the icon bar or is over
  557. the window workarea.
  558.  
  559. None
  560.  
  561. None
  562.  
  563.  
  564. Wimp_PreProcessKey (Interface_PreProcessKey) (SWI &81688)
  565.  
  566. R0 = event type
  567. R1 = event block
  568. R2 = task handle
  569.  
  570. R0 = updated to new event type
  571. R1 = updated event block
  572. R2 = 0 if event was not dealt intercepted
  573.  
  574. This call pre-processes the up, down, tab, shift-tab keys and any specified
  575. in a specific icons validation string using the command k<keycode>. The SWI
  576. will move icon, if neccessary or activate a button. This call should be
  577. called after the wimp_poll command, it will match the key to an icon and if
  578. neccessary modify your wimp poll block and event type.
  579.  
  580.  
  581. Wimp_BorderPlotIcon (Interface_Plot3dIcon) (SWI &81689)
  582.  
  583. R0 = window state (either from wimp_update/redraw or from a wimp_getwindowstate)
  584. R1 = icon block as for Wimp_PlotIcon
  585.  
  586. This call plots a border on a window like Wimp_PlotIcon. The icon block
  587. passed in R1 should contain a block as described for Wimp_PlotIcon in the
  588. PRMs.
  589.  
  590. Wimp_BorderBoundingBox (Interface_BoundingBox) (SWI &8168A)
  591.  
  592. R1 = icon block as for Wimp_PlotIcon
  593.  
  594. R1 = updates icon block
  595.           
  596.           offset
  597.           0         min x
  598.           4         min y
  599.           8         max x
  600.           12        max y
  601.           16        border width
  602.           20        button slab state (1 = out, 0 = in)
  603.  
  604. This call returns information about the icon block passed to it. If you wish
  605. to get the size of an icons box use Wimp_GetIconState and then pass the icon
  606. block returned to this function.
  607.  
  608.  
  609.  
  610. Changes from version 1.32
  611.  
  612. this version has been fully re-written using the acorn aof assembler.
  613. border type has changed to z to avoid conflicts with risc-os 3
  614. Interface_Plot3dIcon has been changed so the first parameter is a window
  615. state block instead of a window handle  names has changed to interface_....,
  616. old names are still supported better redraw code to correct problems with
  617. multi-sync modes where the icons were not alligned correctly.
  618. Interface_BoundingBox now returns the state of the button new border types
  619.  
  620. *command to allow changes in the slabbing colours.